from MySQLhelper import get_sql_helper
from common.util.TimeUtil import *

sqlhelper = get_sql_helper()

def get_all_moudle():
    return sqlhelper.fetch_all("select * from rpa_moudle",())

def get_moudle_by_id(moudle_id):
    return sqlhelper.fetch_all("select * from rpa_moudle where id = %s",(moudle_id))

def insert_moudle(moudle_name, moudle_desc):
    create_time = get_today()
    sqlhelper.insert_one(
        "INSERT INTO rpa_moudle (moudle_name, moudle_desc, create_time) VALUES(%s, %s, %s); ",
        (
            moudle_name, moudle_desc, create_time))

def delete_moudle(moudle_id):
    sqlhelper.delete("DELETE from rpa_moudle where moudle_id = %s", (moudle_id))